package com.cn.kabalifeuser.ui.service.activity;

import com.cn.kabalifeuser.api.Api;
import com.cn.kabalifeuser.base.BasePresenter;
import com.cn.kabalifeuser.callback.CacheCallBack;
import com.cn.kabalifeuser.config.Constants;
import com.cn.kabalifeuser.ui.my.bean.CooperationSreviceListBean;
import com.cn.kabalifeuser.utils.LoggerUtils;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;

/**
 * Created by 晓林 on 2020/9/11.
 * function:
 */
public class TypeBusinessPresenter extends BasePresenter<TypeBusinessView> {

    public void onCooperationSreviceListData() {
        OkGo.<CooperationSreviceListBean>get(Api.API_INDEX_SREVICE_TYPE_LIST)
                .params("type", 1)
                .execute(new CacheCallBack<CooperationSreviceListBean>() {
                    @Override
                    public void onSuccess(Response<CooperationSreviceListBean> response) {
                        super.onSuccess(response);
                        LoggerUtils.e("list" + response.body());
                        if (isViewAttached())
                            if (response.body().getCode() == Constants.HTTP_SUCCESS)
                                getView().onCooperationSreviceListSuccess(response.body());
                            else if (response.body().getCode() == Constants.HTTP_AGAIN_LOGIN)
                                getView().onReLoggedIn(response.body().getMsg());
                            else
                                getView().onError(response.body().getMsg());
                    }
                });
    }
}
